import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Imp implements Comparator<Integer> {

    //compareTo的底层是用compare方法写的，compare方法默认实现创建小根堆
    @Override
    public int compare(Integer o1, Integer o2) {
        return o1.compareTo(o2);  //这里调用compareTo方法是因为Integer类实现了Comparable接口，里面重写了compareTo方法
    }
}
public class test {

    public static void main(String[] args) {
        //手动创建一个比较器
        Imp imp = new Imp();

        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(imp);
        priorityQueue.offer(6);
        priorityQueue.offer(5);
        priorityQueue.offer(10);

        System.out.println(priorityQueue.poll());
        System.out.println(priorityQueue.poll());

    }
}
